﻿//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Common Core Extensions
//===============================================================================

using System;
using EntLibContrib.Common.Properties;

namespace EntLibContrib.Common.Configuration.Design.Editors
{
	/// <summary>
	/// Specifies a file filter to use with the <see cref="FilteredFileNameEditor"/>.
	/// </summary>
	/// <remarks>This attributes uses the <see cref="InternalResources"/> class to get the filter with the given key</remarks>
	[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")]
	[AttributeUsage(AttributeTargets.Property)]
	public sealed class FileFilterAttribute : Attribute
	{
		#region Fields
		private string filter;
		#endregion

		#region Properties
		/// <summary>
		/// Gets the filter for the dialog.
		/// </summary>
		/// <value>The filter for the dialog.</value>
		public string Filter
		{
			get { return filter; }
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initialize a new instance of the <see cref="FileFilterAttribute"/> class with the filter key.
		/// </summary>
		/// <param name="filterKey">The filter key.</param>
		public FileFilterAttribute(string filterKey)
		{
			if (String.IsNullOrEmpty(filterKey))
				throw new ArgumentNullException("filterKey");

			this.filter = InternalResources.ResourceManager.GetString(filterKey, InternalResources.Culture);
		}
		#endregion
	}
}
